<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title>HTML Converter</title>
	<style type="text/css">
		#wrapper {
			margin: 20px;
		}
		textarea {margin: 20px 0;width: 500px; height: 200px; display: block;}
	</style>
	<script type="text/javascript">
		function convert() {
			var content = document.getElementById('content');
			var textReplace = content.value;
			var cb = document.getElementById('cb3');
			//Replace &
			if (cb.checked == true)
				textReplace = textReplace.replace(/\&/ig,'&amp;');
			//Replace <
			var cb = document.getElementById('cb1');
			if (cb.checked == true)
				textReplace = textReplace.replace(/\</ig,'&lt;');
			//Replace >
			var cb = document.getElementById('cb2');
			if (cb.checked == true)
				textReplace = textReplace.replace(/\>/ig,'&gt;');
			//Replace "
			var cb = document.getElementById('cb4');
			if (cb.checked == true)
				textReplace = textReplace.replace(/\"/ig,'&quot;');
			//Replace '
			var cb = document.getElementById('cb5');
			if (cb.checked == true)
				textReplace = textReplace.replace(/\'/ig,'&#039;');
			var result = document.getElementById('result');
			result.value = textReplace;	
		}
	</script>
</head>
<body>
	<div id="wrapper">
		<textarea id="content">Paste your HTML here</textarea>
		<input type="checkbox" name="" id="cb1" />Convert < to &amp;lt;<br/>
		<input type="checkbox" name="" id="cb2" />Convert > to &amp;gt;<br/>
		<input type="checkbox" name="" id="cb3" />Convert & to &amp;amp;<br/>
		<input type="checkbox" name="" id="cb4" />Convert " to &amp;quot;<br/>
		<input type="checkbox" name="" id="cb5" />Convert ' to &amp;#039;<br/>
		<input type="button" value="Convert" id="btn" onclick="convert()" />
		<textarea id="result" onclick="this.select()">Your result will be here</textarea>	
	</div>
</body>
</html>